package com.bocloud.mq;

import com.rabbitmq.client.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.amqp.RabbitProperties;
import org.springframework.stereotype.Component;

/**
 * rabbitmq接受消息类
 */
@Component
public class RabbitmqProcees {

    Logger log = LoggerFactory.getLogger(RabbitmqProcees.class);

    @Autowired
    RabbitTemplate rabbitTemplate;


    //@RabbitHandler
    @RabbitListener(queues = "login")
    public void process(Message message, Channel channel) throws Exception {
        log.info("message = " + new String(message.getBody()));
        log.info("message =" + message.getMessageProperties());
    }

    @RabbitListener(queues = "login1")
    public void process1(Message message) throws Exception {
        log.info("message1 = " + new String(message.getBody()));
        log.info("message1 =" + message.getMessageProperties());
    }

    @RabbitListener(queues = "login2")
    public void process2(Message message) throws Exception {
        log.info("message2 = " + new String(message.getBody()));
        log.info("message2 =" + message.getMessageProperties());
    }

}
